package com.sw.study.scn.service.impl;

import com.sw.study.scn.dao.UserDao;
import com.sw.study.scn.pojo.Token;
import com.sw.study.scn.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    public Token saveToken(String email, String password) {
        Token Token = new Token();
        Token.setEmail(email);
        Token.setToken(email+"_"+password);
        return userDao.save(Token);
    }

  @Override
  public Token findOne(String token) {
    Token Token = new Token();
    Token.setToken(token);
    Example<Token> example = Example.of(Token);
    return userDao.findOne(example).get();
  }
}
